package y_2025.m03.d22;

import java.util.Scanner;

public class Exception_ {
    public static void main(String[] args) {
        try {
            int a = 2;
            int b = 0;
            // int c = a/b;
            String s = null;
            System.out.println("s.length() = " + s.length());
        } catch (ArithmeticException e) {
            System.out.println("e = " + e);
        } catch (NullPointerException e) {
            System.out.println("e = " + e);
        } catch (Exception e) {
            System.out.println("e = " + e);
        } finally {
            System.out.println("=========");
        }
    }
}

class Exception_02 {
    public static int f() {
        int i = 0;
        try {
            String s = null;
            System.out.println("s.length() = " + s.length());
        } catch (Exception e) {
            System.out.println(e.getMessage());
            System.out.println("================");
            return 111;

        } finally {
            System.out.println("-----------------");
            return 222;
        }
    }
    public static void main(String[] args) {
        System.out.println("f() = " + f());
    }
}

class Exception_03{
    public static void main(String[] args) {
        int res;
        while (true) {
            Scanner scanner = new Scanner(System.in);
            String s = scanner.nextLine();
            try {
                res = Integer.parseInt(s);
                break;
            } catch (NumberFormatException e) {
                System.out.println(e.getMessage());
            }
        }

        System.out.println(res);
    }
}